<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
        <meta name="format-detection" content="telephone=no"/>
        <title>简单的页面容器</title>
        <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
        <style>
            body {
                background-color: #f2f2f2;
            }
            #statusHeader {
                background-color: #db4537;
            }
        </style>
    </head>
    <body>
        <div id="statusHeader"></div>
    </body>
    <script src="../../script/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/debug.js"></script>
    <script type="text/javascript" src="../../script/constant.js"></script>
    <script type="text/javascript" src="../../script/config.js"></script>
    <script type="text/javascript" src="../../script/common.js"></script>
    <script type="text/javascript" src="../../script/navigate.js"></script>
    <script type="text/javascript">
        
        /**
         * 处理返回事件
         */ 
        function handlerBackBtn() {w
            api.addEventListener({
                name : 'keyback'
            }, function(ret, err) {
                //operation
                var currentWinName = getFrameName(); //当前窗口的名字
                
                if(currentWinName == "login"){
                    logout();
                }else if(currentWinName == "home_win"){
                    
                }else{
                    api.historyBack();
                }
            });
        }
        
        /**
         *退出系统操作  只限于android
         */
        function logout(){
            
            api.confirm({
                title: '提示',
                msg: '确定退出系统？',
                buttons:['取消', '确定']
            },function(ret,err){
                if(ret.buttonIndex == 2){
                    api.closeWidget({
                        id: api.appId,
                        retData: {name:'closeWidget'},
                        animation: {
                            type: 'flip',
                            subType: 'from_bottom',
                            duration: 500
                        }
                    });
                }
            });

        }

        //简单的页面容器，只负责对IOS的状态栏进行填充颜色
        apiready = function() {
            //在IOS下适应状态栏的显示
            var header = $api.byId('statusHeader');
            if (api.pageParam && api.pageParam.backgroundColor) {
                $api.attr(header, "style", "background-color:" + api.pageParam.backgroundColor + ";");
                ;
            }
            $api.fixIos7Bar(header);
              //打开主框体的内容
            openMainFrame();
            
            handlerBackBtn();
          
        };
        
        /**
         *打开主窗体的东西
         */
        function openMainFrame() {
            var targetUrl = getAbsoluteUrl(api.pageParam.url);
            //alert(targetUrl+","+api.frameName);
            var winWidth = api.frameWidth;
            var winHeight = api.frameHeight;
            var systemType = api.systemType;
            var y = 0;
            if (systemType == "ios") {
                y += 20;
            }
            api.openFrame({
                name : getFrameName() + "_main",
                url : targetUrl,
                bounces : false,
                pageParam : api.pageParam,
                rect : {
                    x : 0,
                    y : y,
                    w : winWidth,
                    h : winHeight
                }
            });
        }
    </script>
</html>